@extends('layouts.console_header')

@section('title', '代理商对账单')

@section('resources')
    @parent
<style>
    nav{height: 50px;line-height: 50px;}
    nav a,nav span{margin-left: 20px;}
    nav input{margin-left: 20px;height: 28px;border: 1px solid #000;margin-top: 10px;}
</style>
@endsection

@section('content')
<!--  html内容  -->
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		<span style="color: #7f7f7f;"><a href="/console/index">首页</a>>财务中心></span>
		<span class="co_violet">代理商对账单</span></p>
		<a  href="/console/finance/agent/statement/export?type={{$type}}&starttime={{$starttime}}&lasttime={{$lasttime}}"  target="_blank"><p class="fr tc back_btn">导出</p></a>
	</div>
    <table class="finance_top_list">
        <tr>
            <th>代理商数</th>
            <th>代理商收入（元）</th>
            <th>已提现金额(元)</th>
            <th>待提现金额(元)</th>
            <th>当月收入</th>
        </tr>
        <tr>
            <td>{{$agentcount}}</td>
            <td>{{$agentProfitTotal}}</td>
            <td>{{$agentwithdrawal}}</td>
            <td>{{$agentwaitwithdrawal}}</td>
            <td>{{$thismonthAmountTotal}}</td>
        </tr>
    </table>
    <nav>
        <a class="fl" href="/console/finance/agent/statement?type=today">今日</a>
        <a class="fl" href="/console/finance/agent/statement?type=yesterday">昨日</a>
        <a class="fl" href="/console/finance/agent/statement?type=week">本周</a>
        <a class="fl" href="/console/finance/agent/statement?type=thismonth">本月</a>
        <a class="fl" href="/console/finance/agent/statement?type=lastmonth">上月</a>
        <a class="fl" href="/console/finance/agent/statement?type=all">全部</a>
        <span class="fl">时段选择</span>
        <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
        <span class="fl">至</span>
        <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
    </nav>
	<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                <th>代理商编号</th>
                <th>代理商类型</th>
                <th>代理城市</th>
                <th>订单笔数</th>
                <th>订单消费金额</th>
                <th>[代理商]服务费收入(元)</th>
                <th>[代理商]已使用红包(元)</th>
                {{--<th>[代理商]过期退回红包(元)</th>--}}
                <th>代理商收入(元)</th>
                <th>已提现金额(元)</th>
                <th>待提现金额(元)</th>
                <th>操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>序号</th>
                <th>代理商编号</th>
                <th>代理商类型</th>
                <th>代理城市</th>
                <th>订单笔数</th>
                <th>订单消费金额</th>
                <th>[代理商]服务费收入(元)</th>
                <th>[代理商]已使用红包(元)</th>
                {{--<th>[代理商]过期退回红包(元)</th>--}}
                <th>代理商收入(元)</th>
                <th>已提现金额(元)</th>
                <th>待提现金额(元)</th>
                <th>操作</th>
            </tr>
        </tfoot>
        <tbody>
            @foreach($lists as $list)
            <tr>
            @if(!isset($i))
                <td>{{$i=1}}</td>
            @else
                <td>{{++$i}}</td>
            @endif
                <td>{{$list['cityid']}}</td>
                <td>市代</td>
                <td>{{$list['cityname']}}</td>
                <td>{{$list['ordercount']}}</td>
                <td>{{$list['orderamount']}}</td>
                <td>{{$list['fee']}}</td>
                <td>-{{$list['redenvelopeamount']}}</td>
{{--                <td>+{{$list['redenveloperefundamount']}}</td>--}}
                <td>{{$list['agentprofit']}}</td>
                <td>{{$list['withdrawalamount']}}</td>
                <td>{{$list['waitwithdrawalamount']}}</td>
                <td><a class="co_violet" href="/console/finance/agent/statement/details?agentcityid={{$list['cityid']}}&type={{$type}}&starttime={{$starttime}}&lasttime={{$lasttime}}">明细</a></td>
            </tr>
            @endforeach
        </tbody>
    </table>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        function select_date() {
            var cityid = "{{$cityid}}";
            var startTime = $("input[name='starttime']").val();
            var lastTime = $("input[name='lasttime']").val();
            if(!startTime || !lastTime) {
                alert('请选择开始时间和结束时间'); return;
            }
            window.location.href="/console/finance/agent/statement?cityid=" + cityid+"&starttime="+startTime+"&lasttime="+lastTime;
        }
    </script>
@endsection